aboutsummaryrefslogtreecommitdiff
path: root/src/pages/create/[board].astro
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2022-08-28 23:22:15 +0300
committerkartofen <mladenovnasko0@gmail.com>2022-08-28 23:22:15 +0300
commit9d952483f250a97cbeab4061fa1c4e68341b330f (patch)
tree9d094911dc5178db9375eaa661e7f4bf0d5bf2cc /src/pages/create/[board].astro
parent35b06b4fc851192916e000ad5e7e2f458846448c (diff)
posting thread and image works
Diffstat (limited to 'src/pages/create/[board].astro')
-rw-r--r--src/pages/create/[board].astro67
1 files changed, 19 insertions, 48 deletions
diff --git a/src/pages/create/[board].astro b/src/pages/create/[board].astro
index 45f8b0d..9c2308f 100644
--- a/src/pages/create/[board].astro
+++ b/src/pages/create/[board].astro
@@ -1,54 +1,25 @@
---
-import Default from '../../layouts/Default.astro'
+import Default from '../../layouts/Default.astro';
+import Form from '../../components/Form.astro';
+
const { board } = Astro.params;
---
-<h1>{board}</h1>
-
<Default>
- <form id="form" method="post" action="/create/thread" onsubmit="document.getElementById('submit-button').disabled = true">
- <textarea name="ThreadName" placeholder="Thread Name" style="height: 1.5rem; width: 350px;"></textarea> <br>
- <textarea name="ThreadText" placeholder="Thread Contents" style="height: 150px; width: 350px;"></textarea>
- <br> <input id="submit-button" type="submit" value="Create Thread" />
- <input id="image" type="file" accept=".png,.jpg,.gif,.bmp,.mp4" />
-
- </form>
- <script define:vars={{ board }}>
- document.forms['form'].addEventListener('submit', async (event) => {
- event.preventDefault();
-
- let form = new FormData(event.target);
- let reader = new FileReader();
-
- reader.onload = e => {
- form.append('image',
- (e != null) ? e.target.result.toString() : ''
- );
- }
-
- reader.onloadend = () => {
- fetch(event.target.action, {
- method: event.target.method,
- body: new URLSearchParams(form)
- }).then((r) => {
- if(r.status == 200) {
- alert('Thread Successfuly Posted');
- window.location.assign(`/board/${board}`);
- }
- else alert('An Error has Accured');
- });
- }
-
- form.append('board', board);
-
- let image = document.getElementById("image").files[0];
- if(image) {
- reader.readAsDataURL(image);
- } else {
- reader.onload(null);
- reader.onloadend();
- }
-
- });
- </script>
+ <h1>{board}</h1>
+
+ <Form board={board} tid="niggers">
+ <form id="form" method="post" action="/create/thread" onsubmit="document.getElementById('submit-button').disabled = true">
+ <textarea name="ThreadName" placeholder="Thread Name" style="height: 1.5rem; width: 350px;"></textarea> <br>
+ <textarea name="ThreadText" placeholder="Thread Contents" style="height: 150px; width: 350px;"></textarea>
+ <br> <input id="submit-button" type="submit" value="Create Thread" />
+ <input id="image" type="file" accept=".png,.jpg,.gif,.bmp,.mp4" />
+ </form>
+ </Form>
</Default>
+
+<style>
+ :root {
+ --wdt: 360px;
+ }
+</style>